What CBorn is talking about is a way to gather entropy from the keyboard. Linux gathers entropy too through all kinds of device noise and/or user actions. Those ( for all intents and purposes ) true random numbers can then be used to seed a PRNG.
What CBorn is talking about is a way to gather entropy from the keyboard. Linux gathers entropy too through all kinds of device noise and/or user actions. Those ( for all intents and purposes ) true random numbers can then be used to seed a PRNG.
Devoted my life to programming...
I know exactly what he's talking about. The point is that it has nothing to do with SarasMuthu's question and can only confuse the issue. In that sense it is incoherent (to the OP) and misses the point entirely.
Last edited by algorism; 05-01-2017 at 03:36 PM.
Th
Thanks algorism. Through your program, i can generate random values like 0's and 1's.
I am very poor in programming side. Just start learning. Can you give pseudocode/algorithm for your code.
Thanks algorism . With the help of your program codes, i am able to generate Random bits like 0`s and 1's. I am very poor in programming sides, i am just start learning for my project work. Can you give pseudocode/algorithm for above program.
I'm not sure what you mean.
Also, beware that the given code always produces the same sequence of bits. To have it produce different sequences you would need to "seed" the lfsr with some arbitrary value each time you run the program. The simplest method is to use the current time. For hardcore uses there are much better ways to seed the generator, and of course the generator function itself would need to be tested for decent randomness.
Code:#include <stdio.h> #include <time.h> static unsigned lfsr = 0x5; int PRBS_prj() { int bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 4) ) & 1; lfsr = (lfsr >> 1) | (bit << 7); return bit; } int main() { lfsr = (unsigned)time(NULL); for (int i = 0; i < 100; i++) printf("%d", PRBS_prj()); putchar('\n'); return 0; }
"missing the point" is entirely different from " ignore"
think OUT of the BOX you just programmed your self in.
i tried to explain that there is NO real random in any computer OS.
so, the USER comes in at that point... the only NON digital influence within the system, i supose.
GReaper mentions that many influences exist. very well indeed, good point.
maybe a XOR over some databus input will give a resonable "real random".
programs are made for users, right ?
I don't think "prepared tables" are likely: as you know from srand and rand more likely a PRNG using one of the common mathematical methods for pseudorandom integers would be used instead, and if the floating point range between 0 and 1 is needed, a mapping function would be used.Originally Posted by CBorn
Hence, what to choose depends on why you want the random numbers: without knowing why SarasMuthu started by using a "pseudorandom bit sequence generator", your suggestion could well be off the mark since it does not suggest a PRNG. For plenty of kinds of tasks, e.g., simulating some mathematical model, a good PRNG will suffice. For some other tasks, a cryptographically secure PRNG would suffice, perhaps seeded with entropy from a "real" random source. A poorly done "real" random number generator may well be worse for predictability than a cryptographically secure PRNG.Originally Posted by CBorn
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)